<style scoped>
  .expand-row{
    margin-bottom: 16px;
  }
  .lyx-table-btn{
    margin-right: 5px;
    margin-bottom: 2px;
  }
  .title-size {
    font-weight: bold;
    font-size: 1rem;
  }
  .ml2 {
    margin-left: 2px;
  }
</style>
<template>
  <div>
      <Form label-position="right" :label-width="100" style="position: relative;" :model="formDate">
        <Row class="mb20">
          <Col span="14" class="ivu-form-item-label title-size">廉租房转社区受理情况</Col>
        </Row>
        <Row class="mb20">
          <Col span="8" class="ivu-form-item-label">申请人姓名：</Col>
          <Col span="9" offset="1" class="ivu-form-item-content">
            <Input v-model="formDate.applyPerson"></Input>
          </Col>
        </Row>
        <Row class="mb20">
          <Col span="8" class="ivu-form-item-label">身份证号：</Col>
          <Col span="9" offset="1" class="ivu-form-item-content">
            <Input v-model="formDate.applyIdCard" ></Input>
          </Col>
        </Row>
        <Row class="mb20">
          <Col span="8" class="ivu-form-item-label">家庭原始户籍所在区域：</Col>
          <Col span="9" offset="1" class="ivu-form-item-content">
            <Input v-model="formDate.yundizhi"></Input>
          </Col>
        </Row>
        <Row class="mb20">
          <Col span="8" class="ivu-form-item-label">家庭要转到的区域：</Col>
          <Col span="3" offset="1">
            <Select v-model="formDate.qxId" @on-change="bb">
              <Option v-for="item in sectionList" :value="item.id" :key="item.id">{{ item.title }}</Option>
            </Select>
          </Col>
          <Col span="3" class="ml2">
            <Select v-model="formDate.jdId" @on-change="cc">
              <Option v-for="item in sectionListb" :value="item.id" :key="item.id">{{ item.title }}</Option>
            </Select>
          </Col>
          <Col span="3" class="ml2">
            <Select v-model="formDate.company_code" @on-change="getValidateRules()">
              <Option v-for="item in sectionListc" :value="item.company_code" :key="item.id">{{ item.title }}</Option>
            </Select>
          </Col>
        </Row>
        <Row class="mb20">
          <Col span="8" class="ivu-form-item-label">社区经办人：</Col>
          <Col span="9" offset="1" class="ivu-form-item-content">
            <Input v-model="formDate.beginPerson" ></Input>
          </Col>
        </Row>
        <Row class="mb20">
          <Col span="8" class="ivu-form-item-label">申请时间：</Col>
          <Col span="9" offset="1" class="ivu-form-item-content">
            <DatePicker type="date" v-model="formDate.beginDate" style="width: 363px" @on-change="datechange"></DatePicker>
          </Col>
        </Row>
        <Row class="mb20">
          <Col span="8" class="ivu-form-item-label">社区负责人：</Col>
          <Col span="9" offset="1">
            <Input v-model="formDate.committeePrincipal"></Input>
          </Col>
        </Row>
        <Row class="mb20">
          <Col span="8" class="ivu-form-item-label">受理时间：</Col>
          <Col span="9" offset="1" class="ivu-form-item-content">
            <DatePicker type="date" v-model="formDate.acceptDate" style="width: 363px"></DatePicker>
          </Col>
        </Row>
        <Row class="mb20">
          <Col span="13" class="ivu-form-item-label">
            <Button @click="save()">提交</Button>
          </Col>
        </Row>
      </Form>
  </div>
</template>
<script>
// import { itemParamByOrderList } from '@/api/eventlist'
import { getMailLevelList, getSQCodeFc, date2str } from '@/api/eventlist'
export default {
  name: 'Form13',
  data () {
    return {
      bwk: '0',
      paramsArr: [],
      list: [],
      overReasonFlagList: [],
      sectionList: [],
      sectionListb: [],
      sectionListc: []
    }
  },
  props: {
    formDate: Object,
    ruleData: Object
  },
  mounted () {
    this.bb()
    this.cc(this.formDate.company_code)
    this.getPermanentAddress()
  },
  watch: {

  },
  methods: {
    datechange (data) {
      this.formDate.beginDate = data
    },
    bb () {
      this.sectionListb = []
      let param = { id: this.formDate.qxId }
      console.log(param, '250')
      getMailLevelList(param).then(res => {
        if (res.data.errcode === 0) {
          this.sectionListb = res.data.data
          console.log(this.sectionListb)
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    },
    cc () {
      this.sectionListc = []
      let param = { id: this.formDate.jdId }
      getMailLevelList(param).then(res => {
        if (res.data.errcode === 0) {
          this.sectionListc = res.data.data
          console.log(this.sectionListc)
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    },
    getPermanentAddress () {
      this.sectionList = []
      getMailLevelList().then(res => {
        if (res.data.errcode === 0) {
          this.sectionList = res.data.data
          console.log(this.sectionList)
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    },
    getValidateRules () {
      let q = { company_code: this.formDate.company_code }
      getSQCodeFc(q).then(res => {
        if (res.data.errcode === 0) {
          this.formDate.toSection = res.data.data.qu_code
          this.formDate.toStreet = res.data.data.jiedao_code
          this.formDate.toCommittee = res.data.data.shequ_code
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    },
    save () {
      this.formDate.beginDate = date2str(this.formDate.beginDate)
      this.formDate.acceptDate = date2str(this.formDate.acceptDate)
      console.log(this.formDate)
      if (!this.formDate.toSection) {
        this.$Notice.error({ title: '请选择要转移的区县', desc: '' })
      } else if (!this.formDate.toStreet) {
        this.$Notice.error({ title: '请选择要转移的街道', desc: '' })
      } else if (!this.formDate.toCommittee) {
        this.$Notice.error({ title: '请选择要转移的社区', desc: '' })
      } else if (!this.formDate.beginPerson) {
        this.$Notice.error({ title: '请填写社区经办人', desc: '' })
      } else if (this.formDate.beginDate === undefined) {
        this.$Notice.error({ title: '请填写申请时间', desc: '' })
      } else if (this.formDate.acceptDate === undefined) {
        this.$Notice.error({ title: '请填写受理时间', desc: '' })
      } else if (!this.formDate.committeePrincipal) {
        this.$Notice.error({ title: '请填写社区负责人', desc: '' })
      } else {
        console.log(this.formDate)
        this.$emit('ee')
      }
    }

  }
}
</script>
